import api from '../../api/index'
import * as types from '../mutation-types';

const state = {
  applyList: [],

  applyInfo: [],

  applyNum: [],
  developSelect: []
}

const actions = {
  getApplyList({
    commit
  }, params) {
    api.get_party_develop_list(params).then(res => {
      commit(types.GET_APPLY_LIST, res)
    })
  },
  getApplyInfo({
    commit
  }, params) {
    api.get_apply_info(params).then(res => {
      commit(types.GET_APPLY_INFO, res)
    })
  },
  getAppLyNum({
    commit
  }, params) {
    api.get_apply_num(params).then(res => {
      commit(types.GET_APPLY_NUM, res)
    })
  },
  getDevelopSelect({
    commit
  }, params) {
    api.get_develop_select(params).then(res => {
      commit(types.GET_APPLY_SELECT, res)
    })
  }
}

const getters = {
  applyList: state => state.applyList,

  applyInfo: state => state.applyInfo,

  applyNum: state => state.applyNum,
  developSelect: state => state.developSelect
}

const mutations = {
  [types.GET_APPLY_LIST](state, res) {
    if (res.code === 0) {
      state.applyList = []
    } else {
      state.applyList = res.data
    }
  },
  [types.GET_APPLY_INFO](state, res) {
    if (res.code === 0) {
      state.applyInfo = []
    } else {
      state.applyInfo = res.data
    }
  },
  [types.GET_APPLY_NUM](state, res) {
    if (res.code === 0) {
      state.applyNum = []
    } else {
      state.applyNum = res.data
    }
  },
  [types.GET_APPLY_SELECT](state, res) {
    if (res.code === 0) {
      state.developSelect = []
    } else {
      state.developSelect = res.data
    }
  }
}

export default {
  state,
  actions,
  getters,
  mutations,
}
